#include "stdafx.h"
#include "GSProto.h"
#include "player_session_event_handler.h"


void DecodeGS_LOGIN_REQ_ID(const void * buf, int nSize, CPlayerSession * pProc)
{
    GS_LOGIN_REQ_PKG pkg;
    if (!pkg.ParseFromArray(buf, nSize))
        return;
    if (pProc){
        pProc->OnRecvLoginReq(&pkg);
    }
}

CGSProto::CGSProto()
{
    GOOGLE_PROTOBUF_VERIFY_VERSION;
    memset(m_DecodeFuncArray, 0, sizeof(m_DecodeFuncArray));
    Init();
}

CGSProto::~CGSProto()
{
    google::protobuf::ShutdownProtobufLibrary();
}

bool CGSProto::Init()
{
    m_DecodeFuncArray[GS_LOGIN_REQ_ID] = &DecodeGS_LOGIN_REQ_ID;
    return true;
}

void CGSProto::Decode(int nMsgID, const void * buf, int nSize, CPlayerSession * pProc)
{
    if(nMsgID > GSProtoMaxMessageID || m_DecodeFuncArray[nMsgID] == NULL){
        return;
    }
    m_DecodeFuncArray[nMsgID](buf, nSize, pProc);
}

